package org.ourgrid.broker.business.schedulerdata.executor;

import java.util.ArrayList;
import java.util.List;

import org.ourgrid.broker.business.schedulerdata.SchedulerData;
import org.ourgrid.broker.response.PauseRequestResponseTO;
import org.ourgrid.common.internal.IResponseTO;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class PauseRequestExecutor extends AbstractSchedulerDataExecutor {
	

	/**
	 * <PAUSE_REQUEST peerID='String' requestID='long'/>
	 */
	
	public List<IResponseTO> execute(SchedulerData command) {
		
		List<IResponseTO> responses = new ArrayList<IResponseTO>();
		
		Document logDocFile = super.getXMl(command.getXml());
		
		Element element = logDocFile.getDocumentElement();
		
		String pID = element.getAttribute("peerID");
		long requestID = Long.valueOf(element.getAttribute("requestID"));
		
		PauseRequestResponseTO to = new PauseRequestResponseTO();
		
		to.setPeerAddress(getAddress(pID));
		to.setRequestID(requestID);
		
		responses.add(to);
		
		return responses;
	}
}
